﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FinModel
{
    public class Portfolio
    {
        private List<Position> _positions = new List<Position>();

        public Position[] Positions { get { return _positions.ToArray(); } }

        public void Add(Instrument instrument)
        {
            _positions.Add(new Position()
            {
                Instrument = instrument,
                Quantity = 0
            });
        }

        public Position this[string instrumentName]
        {
            get { return _positions.SingleOrDefault(p => p.Instrument.Name == instrumentName); }
        }
        public Position this[Instrument instrument]
        {
            get { return this[instrument.Name]; }
        }
    }
}
